/**
 * Created by abdulazizalonizi on 8/8/17.
 */
public class Box {

    private double length , width , height;

    public Box(double length , double width , double height)
            throws IllegalArgumentException
    {
        if(length <= 0 || width <= 0 || height <= 0)
            throw new IllegalArgumentException("Error: Dimension <= 0");

        this.length = length;
        this.width = width;
        this.height = height;
    }

    public Box(double length)
    {
        this(length,length,length);
    }

    public Box(Box other)
    {
       this.height = other.height;
       this.length = other.length;
       this.width = other.width ;

    }

    public String toString()
    {
        return "Length :"+this.length+" ,Width :"+this.width+" ,Height :"+this.height;
    }

    public boolean equals(Object other)
    {
        if (other instanceof Box)
        {
            Box otherBox = (Box) other ;
            if (otherBox.height == this.height & otherBox.width == this.width & otherBox.length == this.length)
            {
                return true ;
            }
            else
                return false ;
        }else
        {
            throw new IllegalArgumentException("Error :not same type argument!");
        }
    }

    public void setLength (double length)
    {
        if (length <= 0 )
        throw new IllegalArgumentException("Error: Dimension <= 0");

        this.length = length;
    }
    public void setWidth (double width)
    {
        if (width <= 0 )
            throw new IllegalArgumentException("Error: Dimension <= 0");

        this.width = width;
    }
    public void setHeight (double height)
    {
        if (height <= 0 )
            throw new IllegalArgumentException("Error: Dimension <= 0");

        this.height = height;
    }

    public double getLength()
    {
        return this.length ;
    }
    public double getWidth()
    {
        return this.width ;
    }
    public double getHeight()
    {
        return this.height ;
    }

    public double volume( )
    {
        return length * width * height;
    }

    public double surfaceArea( )
    {
        return 2*(length*width + length*height + width*height);
    }
}
